import QtQuick 2.0
import QtQuick.Shapes 1.14
import QtGraphicalEffects 1.14
import QtQuick.Extras 1.4
import Qt.labs.platform 1.1
import QtQuick.Controls 2.14
import QtQuick 2.14


Item {
    id:root
    implicitHeight:583
    implicitWidth: 424

    Connections{
        target: swipeinterface

        function onFileListChanged()
        {
            console.log("onFileListChanged  "+ swipeinterface.fileList[0]["icon_path"])
            console.log("onFileListChanged  "+ swipeinterface.fileList[0]["md5id"])
            console.log("onFileListChanged  "+ swipeinterface.fileList[0]["abs_path"])
        }

        function onSysResize()
        {
            root.width = swipeinterface.width()
            root.height = swipeinterface.height()
            // folder.x=100
        }


    }

    Rectangle{
        anchors.fill: parent

        GridView{
            id:gridView
            cellWidth:parent.width / 4 - 10
            cellHeight:parent.height / 2
            anchors.fill: parent
            anchors.top: parent.top
            anchors.topMargin: 10
            anchors.left: parent.left
            anchors.leftMargin: 20
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 10
            model: printControl.fileList
            //clip:true   // 超出边界的进行裁剪，即不显示，默认为false
            //boundsBehavior:  Flickable.StopAtBounds  // 滑动不超出父框的大小
            //boundsMovement: Flickable.StopAtBounds
            boundsBehavior: Flickable.DragOverBounds
            interactive: true
            cacheBuffer: 100

            property string currentSelectFile : ""

            MouseArea {
                anchors.fill: parent
                propagateComposedEvents: true
                z:-10
                onClicked: {
                    mouse.accepted = false
                }
            }

            delegate:ExFileItem{
                id:img
                name: modelData["name"]
                type: modelData["type"]
                abs_path: modelData["abs_path"]
                cur_path:modelData["cur_dirpath"]
                btnType: bar.tabInx
                //isSelected: modelData["isSelected"]
                curViewSize: control.position
                onLastTapFile:{
                    gridView.currentSelectFile = fileName
                }
            }

            ScrollBar.vertical: ScrollBar{
                id:control
                padding: 0
                policy: ScrollBar.AsNeeded
                anchors.right: gridView.right
                anchors.rightMargin: 10
                opacity:(control.policy === ScrollBar.AlwaysOn || control.size < 1.0)?1.0:0.0
                stepSize:0.5
                wheelEnabled: true
                snapMode:ScrollBar.NoSnap
                contentItem: Rectangle{
                    implicitWidth: 8
                    height: 2
                    radius: 5
                    color: control.pressed?"#1989FA":"#4CA1F6"
                }
                background: Rectangle{
                    color: "#C3C3C3"
                    radius: 5
                }
            }
        }
    }

}
